import { Message } from 'element-ui';
import { Loading } from 'element-ui';

class ZZToast {
  static loadingInstance = null;
  static loading() {
    this.loadingInstance = Loading.service({
      fullscreen: true,
      background: 'rgba(24,31,75, 0)',
      text: '加载中...'
    });
  }

  static warn(msg) {
    Message({
      message: msg,
      showClose: true,
      duration: 2000,
      type: 'warning'
    });
  }

  static success(msg) {
    Message({
      message: msg,
      showClose: true,
      duration: 2000,
      type: 'success'
    });
  }

  static hide() {
    if (this.loadingInstance !== null) {
      this.loadingInstance.close();
    }
  }
}

export default ZZToast;
